﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Project01
{
    class Player03 : Player //tạo player
    {

        public Player03(Game game)
            : base(game)
        {
            ObjectTexture = game.Content.Load<Texture2D>("Images/Player/Type02/PType02");
            Sprite = new AnimationSprite(ObjectTexture, 1, 1);
            this.Sprite.Position = new Vector2(game.Window.ClientBounds.Width / 2 - Sprite.RecWidth / 2, game.Window.ClientBounds.Height);
            this.game = game;
            Speed = 10;

            // tạo Bullets
            BulletAssetname = "Images/Bullets/Player/B_P_Type01";
            BulletRow = 1; 
            BulletCol = 6; 
        }

        public override void Update(GameTime gameTime)
        {

            base.Update(gameTime);
        }
        public override void UpdateBullets(GameTime gameTime)
        {
            for (int i = 0; i < bullets.Count; i++)
            {
                
                bullets[i].Sprite.Position -= new Vector2(0, bullets[i].Speed);
                
                bullets[i].Sprite.Update();
                if (bullets[i].Sprite.Position.Y <= 0 - bullets[i].Sprite.RecHeight)
                {
                    bullets.RemoveAt(i);
                    i--;
                }

            }
            base.UpdateBullets(gameTime);
        }
        public override void Shoot()
        {

            Bullets bullet = new Bullets(game, BulletAssetname, BulletRow, BulletCol);
            bullet.Speed=10;
            bullet.Damage = 6;
            bullet.Sprite.Position = new Vector2(Sprite.Position.X + 50,
                                                  Sprite.Position.Y);
            bullets.Add(bullet);
            bullet = new Bullets(game, BulletAssetname, BulletRow, BulletCol);
            bullet.Speed = 10;
            bullet.Damage = 1;
            bullet.Sprite.Position = new Vector2(Sprite.Position.X, 
                                                  Sprite.Position.Y);


            bullets.Add(bullet);

            base.Shoot();
        }

        public override void Draw(SpriteBatch SpriteBatch)
        {
            foreach (Bullets bullet in bullets)
            {
                bullet.Draw(SpriteBatch);
            }
            base.Draw(SpriteBatch);
        }
    }
}
